IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'CreditCreate')
	BEGIN
		DROP  Procedure  CreditCreate
	END

GO

CREATE Procedure CreditCreate
(
	@accountId int,
	@reference nvarchar(50),
	@details nvarchar(MAX),
	@creditDate datetime,
	@amount money,
	@creditId int OUTPUT
)
AS

INSERT INTO Credits
	(AccountId, Reference, Details, Amount, CreditDate, CreateDate, UpdateDate)
VALUES
	(@accountId, @reference, @details, @amount, @creditDate, GETDATE(), GETDATE())
	
SET @creditId = SCOPE_IDENTITY()

GO